layui.config({
    base : "/js/"
}).extend({
    "mframe" : "mframe"
})

layui.use(['form','layer','mframe'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        mframe = layui.mframe,
        $ = layui.jquery;
    
    
   $(".close").click(function(){
	   var index = parent.layer.getFrameIndex(window.name);
   		parent.layer.close(index);
   })
    
   form.verify({
	 pass: [
	    /^[\S]{6,12}$/,
	    '密码必须6到12位，且不能出现空格'
	  ] 
	});      
      
    form.on("submit(resetPwd)",function(data){
        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        debugger;
        $.ajax({
    		type : "POST",
    		url : ctx + "system/user/resetPwd",
    		data : {
    			"userId":data.field.userId,
    			"loginName": data.field.loginName,
    			"password": data.field.password,
    		},
    		success : function(data) {
    			top.layer.close(index);
                top.layer.msg(data.msg);
                layer.closeAll("iframe");
                //刷新父页面
                parent.location.reload();
    		}
    	});
        return false;
    })
})